package com.fastwire.carriere.rad.entityVo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

import com.fastwire.carriere.inventory.vo.CrossConnectVo;
import com.fastwire.carriere.inventory.vo.EquipmentVo;
import com.fastwire.carriere.inventory.vo.FDFrVo;
import com.fastwire.carriere.inventory.vo.NetworkElementVo;
import com.fastwire.carriere.inventory.vo.SlotVo;
import com.fastwire.carriere.inventory.vo.SubrackVo;
import com.fastwire.carriere.inventory.vo.TerminationPointVo;
import com.fastwire.carriere.inventory.vo.TopologicalLinkVo;
import com.fastwire.carriere.rad.entity.Rad;
import com.fastwire.carriere.rad.entity.RadTermPoint;

/*
 * Creted on 20120225
 * @author: Lei Jun
 */
@Root(name = "Rad")
public class RadVo
{
    @Element(required = false, name = "ipAddress")
    private String ipAddr;

    @Element(required = false)
    private String swVersion;

    @Element(required = false)
    private String sysDescr;

    @Element(required = false)
    private String sysObjectID;

    @Element(required = false)
    private String sysUpTime;

    @Element(required = false)
    private String sysContact;

    @Element(required = false, name = "nativeEmsName")
    private String sysName;

    @Element(required = false)
    private String sysLocation;

    @Element(required = false)
    private String sysServices;

    private String defaultGWValidate;

    private Date discoveryDate;

    private String status;

    @Element(required = false, name = "neType")
    private String type = "Rad";

    @Element(required = false)
    private String slot;   // can delete !!!
    
    @Element(required = false)
    private Set<RadTermPointVo> termPoints;
    
    public RadVo()
    {

    }

    public RadVo(Rad rad)
    {
        ipAddr = rad.getIpAddr();
        swVersion = rad.getSwVersion();
        sysDescr = rad.getSysDescr();
        sysObjectID = rad.getSysObjectID();
        sysUpTime = rad.getSysUpTime();
        sysContact = rad.getSysContact();
        sysName = rad.getSysName();
        sysLocation = rad.getSysLocation();
        sysServices = rad.getSysServices();
        defaultGWValidate = rad.getDefaultGWValidate();
        discoveryDate = rad.getDiscoveryDate();
        status = rad.getStatus();
        
        termPoints = new HashSet<RadTermPointVo>();
        for (RadTermPoint tp : rad.getTermPoints())
        {
            termPoints.add(new RadTermPointVo(tp)) ;
        }        
    }

    // added by Jun on 20120326
    //  adjust to NE for display
    public NetworkElementVo toNEVo()
    {
        NetworkElementVo neVo = new NetworkElementVo();
        neVo.setRemarks("Rad");
        //neVo.setOid(this.g);
        neVo.setName(this.getSysName());
        neVo.setNativeEmsName(this.getSysName());
        neVo.setNeType(this.getType());
        neVo.setIpAddress(this.getIpAddr());
        neVo.setSoftwareVersion(this.getSwVersion());

        // 1 subrack
        SubrackVo subrackVo = new SubrackVo("IP-Mux");
        neVo.addSubrack(subrackVo);

        // 1 slot
        SlotVo slotVo = new SlotVo("IP-Mux");
        subrackVo.addSlot(slotVo);
        
        // 1 equipment
        EquipmentVo eqVo = new EquipmentVo();
        eqVo.setName("IP-Mux Rad");
        eqVo.setSlot(slotVo.getNum());
        eqVo.setSubRack("IP-Mux Rad");
        
        slotVo.addEquipment(eqVo);
        
        List<TerminationPointVo> tpList = new ArrayList<TerminationPointVo>();
        for(RadTermPointVo rtp : termPoints)
        {
            TerminationPointVo tpVo = new TerminationPointVo(rtp.getDescr(),
                    Integer.toString(rtp.getSlot()),
                    Integer.toString(rtp.getPort()));
            
            tpVo.setCrossConnects(new ArrayList<CrossConnectVo>());
            tpVo.setFdfrs(new ArrayList<FDFrVo>());
            tpVo.setTopologicalLinks(new ArrayList<TopologicalLinkVo>());
            
            tpList.add(tpVo);
        }
        
        eqVo.setTotalports(String.valueOf(tpList.size()));
        eqVo.setUsedport("");
        eqVo.setTerminationPoints(tpList);
        
        List<SubrackVo> subrackVos = neVo.getSubracks();
        neVo.setSubracks(subrackVos);
        
        return neVo;
    }

    /**
     * @return the slot
     */
    public String getSlot()
    {
        return slot;
    }

    /**
     * @param slot the slot to set
     */
    public void setSlot(String slot)
    {
        this.slot = slot;
    }


    /**
     * @return the ipAddr
     */
    public String getIpAddr()
    {
        return ipAddr;
    }

    /**
     * @param ipAddr the ipAddr to set
     */
    public void setIpAddr(String ipAddr)
    {
        this.ipAddr = ipAddr;
    }

    /**
     * @return the swVersion
     */
    public String getSwVersion()
    {
        return swVersion;
    }

    /**
     * @param swVersion the swVersion to set
     */
    public void setSwVersion(String swVersion)
    {
        this.swVersion = swVersion;
    }

    /**
     * @return the sysDescr
     */
    public String getSysDescr()
    {
        return "RAD " + sysDescr;
    }

    /**
     * @param sysDescr the sysDescr to set
     */
    public void setSysDescr(String sysDescr)
    {
        this.sysDescr = sysDescr;
    }

    /**
     * @return the sysObjectID
     */
    public String getSysObjectID()
    {
        return sysObjectID;
    }

    /**
     * @param sysObjectID the sysObjectID to set
     */
    public void setSysObjectID(String sysObjectID)
    {
        this.sysObjectID = sysObjectID;
    }

    /**
     * @return the sysUpTime
     */
    public String getSysUpTime()
    {
        return sysUpTime;
    }

    /**
     * @param sysUpTime the sysUpTime to set
     */
    public void setSysUpTime(String sysUpTime)
    {
        this.sysUpTime = sysUpTime;
    }

    /**
     * @return the sysContact
     */
    public String getSysContact()
    {
        return sysContact;
    }

    /**
     * @param sysContact the sysContact to set
     */
    public void setSysContact(String sysContact)
    {
        this.sysContact = sysContact;
    }

    /**
     * @return the sysName
     */
    public String getSysName()
    {
        return sysName;
    }

    /**
     * @param sysName the sysName to set
     */
    public void setSysName(String sysName)
    {
        this.sysName = sysName;
    }

    /**
     * @return the sysLocation
     */
    public String getSysLocation()
    {
        return sysLocation;
    }

    /**
     * @param sysLocation the sysLocation to set
     */
    public void setSysLocation(String sysLocation)
    {
        this.sysLocation = sysLocation;
    }

    /**
     * @return the sysServices
     */
    public String getSysServices()
    {
        return sysServices;
    }

    /**
     * @param sysServices the sysServices to set
     */
    public void setSysServices(String sysServices)
    {
        this.sysServices = sysServices;
    }

    /**
     * @return the defaultGWValidate
     */
    public String getDefaultGWValidate()
    {
        return defaultGWValidate;
    }

    /**
     * @param defaultGWValidate the defaultGWValidate to set
     */
    public void setDefaultGWValidate(String defaultGWValidate)
    {
        this.defaultGWValidate = defaultGWValidate;
    }

    /**
     * @return the discoveryDate
     */
    public Date getDiscoveryDate()
    {
        return discoveryDate;
    }

    /**
     * @param discoveryDate the discoveryDate to set
     */
    public void setDiscoveryDate(Date discoveryDate)
    {
        this.discoveryDate = discoveryDate;
    }

    /**
     * @return the status
     */
    public String getStatus()
    {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status)
    {
        this.status = status;
    }

    /**
     * @return the type
     */
    public String getType()
    {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type)
    {
        this.type = type;
    }

    /**
     * @return the termPoints
     */
    public Set<RadTermPointVo> getTermPoints()
    {
        return termPoints;
    }

    /**
     * @param termPoints the termPoints to set
     */
    public void setTermPoints(Set<RadTermPointVo> termPoints)
    {
        this.termPoints = termPoints;
    }    
    
}
